﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using Gma.System.MouseKeyHook;
using System.Media;
using Dm;

namespace Pubg
{
    public partial class FormMain : Form
    {
        //按键模式
        private string _anjian;
        // 连点计时
        private int _liandianjishi;
        //大漠插件全局变量
        private readonly dmsoft _dm;
        //当前武器
        private int _wepon;
        //武器参数配置文件路径
        private readonly string _strpath;
        //武器1全局倍镜变量
        private string _scope1;
        //武器2全局倍镜变量
        private string _scope2;
        //压枪定时器
        private Timer _timer;
        //识别配件定时器
        private Timer _shiBieTimer;
        //全局压枪幅度
        private string _resfudu;
        //全局键鼠消息钩子
        private IKeyboardMouseEvents _mEvents;

        private readonly SoundPlayer _pldon;

        private readonly SoundPlayer _pldoff;

        private readonly SoundPlayer _pyqon;

        private readonly SoundPlayer _pyqoff;

        private SoundPlayer _plwuqishengying;
        private object _intX;

        private object _intY;

        [DllImport("yxlm.dll")]
        public static extern int DllRegisterServer();

        [DllImport("user32.dll")]
        private static extern IntPtr GetActiveWindow();

        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string defVal, StringBuilder retVal, int size, string filePath);

        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
        public FormMain()
        {
            DllRegisterServer();
            //注册大漠插件
            //_dm = new CDmSoft();
            _dm = (dmsoft)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("26037A0E-7CBD-4FFF-9C63-56F2D0770214")));
            GetActiveWindow();
            //_dm = new CDmSoft();
            //初始化配置文件地址
            _strpath = Directory.GetCurrentDirectory() + "/weapon.ini";
            //设置武器为第一个
            _wepon = 1;
            _pldon = new SoundPlayer(Directory.GetCurrentDirectory() + "/sounds/ONLD.wav");
            _pldoff = new SoundPlayer(Directory.GetCurrentDirectory() + "/sounds/OFFLD.wav");
            _pyqon = new SoundPlayer(Directory.GetCurrentDirectory() + "/sounds/ONYQ.wav");
            _pyqoff = new SoundPlayer(Directory.GetCurrentDirectory() + "/sounds/OFFYQ.wav");
            InitializeComponent();
        }
        private void FormMain_Load(object sender, EventArgs e)
        {
            SubscribeGlobal();
            cbxTouMingDu.Text = @"100%";
            cbxWeapon1.Text = @"无";
            cbxWeapon2.Text = @"无";
            cbxScope1.Text = @"基础镜";
            cbxScope2.Text = @"基础镜";
            cbxQiangKou1.Text = @"无或消音";
            cbxQiangKou2.Text = @"无或消音";
            cbxWoBa1.Text = @"无";
            cbxQiangKou2.Text = @"无";
            cbxQiangTuo1.Text = @"无";
            cbxQiangTuo2.Text = @"无";
            lblsc.Text = @"未知武器";

            //获取屏幕长款
            var bounds = Screen.GetBounds(this);
            var width = bounds.Width;
            var height = bounds.Height;
            int num;
            switch (width)
            {
                case 1920 when height == 1080:
                    num = 0;
                    break;
                case 1536 when height == 864:
                    num = 0;
                    break;
                case 2560 when height == 1440:
                    num = 0;
                    break;
                default:
                    num = 1;
                    break;
            }
            if (num == 0)
            {
                cbxShiBie.Checked = true;
                cbxShiBie.Enabled = true;
            }
            else
            {
                cbxShiBie.Checked = false;
                cbxShiBie.Enabled = false;
            }
            _shiBieTimer = new Timer
            {
                Interval = 20,
                Enabled = false
            };
            _shiBieTimer.Tick += ShiBieTimer_Tick;
            _timer = new Timer
            {
                Interval = 20,
                Enabled = false
            };
            _timer.Tick += timer_Tick;
        }


        #region 按钮事件

        private void ShiBieTimer_Tick(object sender, EventArgs e)
        {
            _shiBieTimer.Interval = 100000000;
            if (!cbxShiBie.Checked)
                _shiBieTimer.Interval = 100;
            else
            {
                var bounds = Screen.GetBounds(this);
                var width = bounds.Width;
                var height = bounds.Height;
                if (width == 1920 && height == 1080)//|| width == 1536 && height == 864
                {
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/M16A4.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "M16A4";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/Scar-L.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "Scar-L";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/UMP-9.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "UMP-9";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/SKS.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "SKS";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/AKM.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "AKM";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/Uzi.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "Uzi";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/DP28.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "DP28";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/M416.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "M416";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/Mini14.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "Mini14";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/Vector.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "Vector";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/VSS.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "VSS";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/汤姆逊.bmp", "000000", 0.9, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "汤姆逊";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/2倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope1.Text = "2倍镜";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/3倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope1.Text = "3倍镜";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/4倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope1.Text = "4倍镜";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/6倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope1.Text = "6倍镜";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/8倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope1.Text = "8倍镜";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/补偿器.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangKou1.Text = "补偿器";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/消焰器.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangKou1.Text = "消焰器";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/垂直握把.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWoBa1.Text = "垂直握把";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/直角握把.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWoBa1.Text = "直角握把";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 131, 1797, 339, Directory.GetCurrentDirectory() + "/sounds/19201080/枪托.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangTuo1.Text = "枪托";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/M16A4.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "M16A4";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/Scar-L.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "Scar-L";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/UMP-9.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "UMP-9";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/SKS.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "SKS";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/AKM.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "AKM";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/Uzi.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "Uzi";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/DP28.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "DP28";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/M416.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "M416";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/Mini14.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "Mini14";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/Vector.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "Vector";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/VSS.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "VSS";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/汤姆逊.bmp", "000000", 0.9, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "汤姆逊";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/2倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope2.Text = "2倍镜";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/3倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope2.Text = "3倍镜";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/4倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope2.Text = "4倍镜";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/6倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope2.Text = "6倍镜";
                    }

                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/8倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope2.Text = "8倍镜";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/补偿器.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangKou2.Text = "补偿器";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/消焰器.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangKou2.Text = "消焰器";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/垂直握把.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWoBa2.Text = "垂直握把";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/直角握把.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWoBa2.Text = "直角握把";
                    }
                    Delay(1);
                    _dm.FindPic(1313, 343, 1823, 566, Directory.GetCurrentDirectory() + "/sounds/19201080/枪托.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangTuo2.Text = "枪托";
                    }

                    if (cbxPlayVoice.Checked)
                    {
                        _plwuqishengying = new SoundPlayer(Directory.GetCurrentDirectory() + "/sounds/ok.wav");
                        _plwuqishengying.Play();
                    }

                    _shiBieTimer.Enabled = false;
                }
                else if (width == 2560 && height == 1440)
                {
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/M16A4.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "M16A4";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/Scar-L.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "Scar-L";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/UMP-9.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "UMP-9";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/SKS.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "SKS";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/AKM.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "AKM";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/Uzi.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "Uzi";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/DP28.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "DP28";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/M416.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "M416";
                    }
                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/Mini14.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "Mini14";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/Vector.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "Vector";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/VSS.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "VSS";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/汤姆逊.bmp", "000000", 0.9, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon1.Text = "汤姆逊";
                    }
                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/2倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope1.Text = "2倍镜";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/3倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope1.Text = "3倍镜";
                    }
                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/4倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope1.Text = "4倍镜";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/6倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope1.Text = "6倍镜";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/8倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope1.Text = "8倍镜";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/补偿器.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangKou1.Text = "补偿器";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/消焰器.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangKou1.Text = "消焰器";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/垂直握把.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWoBa1.Text = "垂直握把";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/直角握把.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWoBa1.Text = "直角握把";
                    }

                    Delay(1);
                    _dm.FindPic(1751, 192, 2389, 453, Directory.GetCurrentDirectory() + "/sounds/25601440/枪托.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangTuo1.Text = "枪托";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/M16A4.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "M16A4";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/Scar-L.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "Scar-L";
                    }
                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/UMP-9.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "UMP-9";
                    }
                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/SKS.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "SKS";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/AKM.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "AKM";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/Uzi.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "Uzi";
                    }
                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/DP28.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "DP28";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/M416.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "M416";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/Mini14.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "Mini14";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/Vector.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "Vector";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/VSS.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "VSS";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/汤姆逊.bmp", "000000", 0.9, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWeapon2.Text = "汤姆逊";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/2倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope2.Text = "2倍镜";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/3倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope2.Text = "3倍镜";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/4倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope2.Text = "4倍镜";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/6倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope2.Text = "6倍镜";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/8倍镜.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxScope2.Text = "8倍镜";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/补偿器.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangKou2.Text = "补偿器";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/消焰器.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangKou2.Text = "消焰器";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/垂直握把.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWoBa2.Text = "垂直握把";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/直角握把.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxWoBa2.Text = "直角握把";
                    }

                    Delay(1);
                    _dm.FindPic(1756, 451, 2389, 737, Directory.GetCurrentDirectory() + "/sounds/25601440/枪托.bmp", "000000", 0.8, 0, out _intX, out _intY);
                    if (Convert.ToInt32(_intX) > 0 && Convert.ToInt32(_intY) > 0)
                    {
                        cbxQiangTuo2.Text = "枪托";
                    }
                    if (cbxPlayVoice.Checked)
                    {
                        _plwuqishengying = new SoundPlayer(Directory.GetCurrentDirectory() + "/sounds/ok.wav");
                        _plwuqishengying.Play();
                    }
                    _shiBieTimer.Enabled = false;
                }
                _shiBieTimer.Interval = 100;
            }
        }
        private void timer_Tick(object sender, EventArgs e)
        {
            //勾选了压枪
            if (cbxSwitch.Checked)
                MouseMoveCommon.MouseMoves(0, Convert.ToInt32(numFuDu.Value.ToString("#.##")));
            //没有勾选连点
            if (!cbxLianXu.Checked) return;z
            if (_liandianjishi >= Convert.ToInt32(txtliandian.Text))
            {
                _anjian = "模拟按键";
                _dm.LeftDown();
                _liandianjishi = 0;
            }
            else
                _liandianjishi += _timer.Interval;
        }


        //bool formSearch = true;
        /// <summary>
        /// 保存当前按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (lblsc.Text == @"未知武器")
            {
                MessageBox.Show(@"请选择武器", @"提示");
            }
            else if (cbxScope1.SelectedIndex > 0 || cbxScope2.SelectedIndex > 0)
            {
                MessageBox.Show(@"保存失败，请把武器1和武器2改成基础镜后保存\r\n倍镜随初始幅度自动添加,无法自行修改的", @"提示");
            }
            else
            {
                int selectedIndex;
                decimal value;
                switch (_wepon)
                {
                    case 1:
                        {
                            selectedIndex = cbxQiangKou1.SelectedIndex;
                            var str = selectedIndex.ToString();
                            selectedIndex = cbxWoBa1.SelectedIndex;
                            var str2 = selectedIndex.ToString();
                            selectedIndex = cbxQiangTuo1.SelectedIndex;
                            var key = str + str2 + selectedIndex;
                            value = numFuDu.Value;
                            var str3 = value.ToString("#.##");
                            value = numPinLv.Value;
                            var value2 = str3 + "|" + value;
                            IniWrite(cbxWeapon1.Text, key, value2, _strpath);
                            break;
                        }
                    case 2:
                        {
                            selectedIndex = cbxQiangKou2.SelectedIndex;
                            var str4 = selectedIndex.ToString();
                            selectedIndex = cbxWoBa2.SelectedIndex;
                            var str5 = selectedIndex.ToString();
                            selectedIndex = cbxQiangTuo2.SelectedIndex;
                            var key = str4 + str5 + selectedIndex;
                            value = numFuDu.Value;
                            var str6 = value.ToString("#.##");
                            value = numPinLv.Value;
                            var value2 = str6 + "|" + value;
                            IniWrite(cbxWeapon2.Text, key, value2, _strpath);
                            break;
                        }
                    default: break;
                }
                MessageBox.Show(@"保存当前配置成功", @"提示");
            }
        }
        #endregion

        #region 方法
        private void SubscribeGlobal()
        {
            Unsubscribe();
            Subscribe(Hook.GlobalEvents());
        }
        private void Subscribe(IKeyboardMouseEvents events)
        {
            _mEvents = events;
            _mEvents.KeyDown += OnKeyDown;
            _mEvents.MouseDown += OnMouseDown;
            _mEvents.MouseUp += OnMouseUp;
        }
        /// <summary>
        /// 鼠标恢复事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMouseUp(object sender, MouseEventArgs e)
        {
            if (cbxSwitch.Checked)
            {
                if (e.Button == MouseButtons.Left)
                {
                    _timer.Enabled = false;
                }

                if (e.Button == MouseButtons.Right && cbxYaoShe.Checked)
                {
                    if (_wepon == 1)
                    {
                        cbxScope1.Text = _scope1;
                    }
                    else if (_wepon == 2)
                    {
                        cbxScope2.Text = _scope2;
                    }
                }
            }

            //RightTag = false;
            //LeftTag = false;
        }
        /// <summary>
        /// 鼠标按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMouseDown(object sender, MouseEventArgs e)
        {
            if (cbxSwitch.Checked)
            {
                if (e.Button == MouseButtons.Left)
                {
                    if (_anjian == "模拟按键")
                    {
                        _anjian = "真实按键";
                        return;
                    }
                    //LeftTag = true;
                    _timer.Interval = Convert.ToInt32(numFuDu.Value.ToString());
                    _timer.Enabled = true;
                }
                if (e.Button == MouseButtons.Right)
                {
                    //RightTag = true;
                    if (cbxYaoShe.Checked)
                    {
                        if (_wepon == 1)
                        {
                            _scope1 = cbxScope1.Text;
                            cbxScope1.Text = @"基础镜";
                        }
                        else if (_wepon == 2)
                        {
                            _scope2 = cbxScope2.Text;
                            cbxScope2.Text = @"基础镜";
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 键盘按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            //if (e.KeyData == Keys.Space)
            //{
            //    var url = Directory.GetCurrentDirectory() + "\\sounds\\19201080\\SKS.bmp";
                
            //    var dmRet = _dm.FindPic(0, 0, 1920, 1080, url, "000000", 0.8, 0, out var intX, out var intY);
            //    if (dmRet != 0)
            //    {
            //        MessageBox.Show(@"没找到");
            //        return;
            //    }
            //    var msg = $"已发现！坐标是：{intX},{intY}";
            //    MessageBox.Show(msg);

            //    return;
            //}
            //开启/关闭连点按键
            if (e.KeyData == Keys.F1)
            {
                if (cbxLianXu.Checked)
                {
                    cbxLianXu.Checked = false;
                    if (cbxPlayVoice.Checked)
                        _pldoff.Play();
                }
                else
                {
                    cbxLianXu.Checked = true;
                    if (cbxPlayVoice.Checked)
                        _pldon.Play();
                }
            }
            //切换手雷近战武器或者收枪之后关闭压枪
            else if (e.KeyData == Keys.D3 || e.KeyData == Keys.D4 || e.KeyData == Keys.D5 || e.KeyData == Keys.X || e.KeyData == Keys.G)
            {
                if (!cbxAutoFire.Checked) return;
                cbxSwitch.Checked = false;
                cbxLianXu.Checked = false;
            }
            //切换1号武器之后恢复压枪
            else if (e.KeyData == Keys.D1)
            {
                lblsc.Text = cbxScope1.Text + cbxWeapon1.Text;
                _wepon = 1;
                try
                {
                    if (cbxWeapon1.Text == @"无")
                        lblsc.Text = @"未知武器";
                    else if (cbxPlayVoice.Checked)
                    {
                        _plwuqishengying = new SoundPlayer(Directory.GetCurrentDirectory() + "/sounds/" + cbxWeapon1.Text + ".wav");
                        _plwuqishengying.Play();
                    }

                    if (cbxAutoFire.Checked)
                    {
                        if (cbxWeapon1.Text == @"M16A4" || cbxWeapon1.Text == @"Mini14")
                            cbxLianXu.Checked = true;
                        else
                            cbxLianXu.Checked = false;
                    }
                    var selectedIndex = cbxQiangKou1.SelectedIndex;
                    var str = selectedIndex.ToString();
                    selectedIndex = cbxWoBa1.SelectedIndex;
                    var str2 = selectedIndex.ToString();
                    selectedIndex = cbxQiangTuo1.SelectedIndex;
                    var skey = str + str2 + selectedIndex;
                    var text = IniReadValue(cbxWeapon1.Text, skey, _strpath);
                    var length = text.IndexOf("|", StringComparison.Ordinal);
                    var value = text.Substring(0, length);
                    numFuDu.Value = Convert.ToDecimal(value);
                    numPinLv.Value = Convert.ToDecimal(text.Split('|')[1]);
                    _resfudu = value;
                    if (cbxScope1.SelectedIndex == 0)
                        numFuDu.Value = Convert.ToDecimal(_resfudu);
                    else if (cbxScope1.SelectedIndex == 1)
                    {
                        if (cbxQiangKou1.SelectedIndex == 0)
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                        else
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                    }
                    else if (cbxScope1.SelectedIndex == 2)
                    {
                        if (cbxQiangKou1.SelectedIndex == 0)
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                        else
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                    }
                    else if (cbxScope1.SelectedIndex == 3)
                    {
                        if (cbxQiangKou1.SelectedIndex == 0)
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                        else
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                    }
                    else if (cbxScope1.SelectedIndex == 4)
                    {
                        if (cbxQiangKou1.SelectedIndex == 0)
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                        else
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                    else if (cbxScope1.SelectedIndex == 5)
                    {
                        if (cbxQiangKou1.SelectedIndex == 0)
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                        else
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
                finally
                {
                    if (cbxAutoFire.Checked)
                        cbxSwitch.Checked = true;
                }
            }
            //切换2号武器之后恢复压枪
            else if (e.KeyData == Keys.D2)
            {
                lblsc.Text = cbxScope2.Text + cbxWeapon2.Text;
                _wepon = 2;
                try
                {
                    if (cbxWeapon2.Text == @"无")
                        lblsc.Text = @"未知武器";
                    else if (cbxPlayVoice.Checked)
                    {
                        _plwuqishengying =
                            new SoundPlayer(
                                Directory.GetCurrentDirectory() + "/sounds/" + cbxWeapon2.Text + ".wav");
                        _plwuqishengying.Play();
                    }
                    if (cbxAutoFire.Checked)
                    {
                        if (cbxWeapon2.Text == @"M16A4" || cbxWeapon2.Text == @"Mini14")
                            cbxLianXu.Checked = true;
                        else
                            cbxLianXu.Checked = false;
                    }
                    var selectedIndex = cbxQiangKou2.SelectedIndex;
                    var str = selectedIndex.ToString();
                    selectedIndex = cbxWoBa2.SelectedIndex;
                    var str2 = selectedIndex.ToString();
                    selectedIndex = cbxQiangTuo2.SelectedIndex;
                    var skey = str + str2 + selectedIndex.ToString();
                    var text = IniReadValue(cbxWeapon2.Text, skey, _strpath);
                    var length = text.IndexOf("|");
                    var value = text.Substring(0, length);
                    numFuDu.Value = Convert.ToDecimal(value);
                    numPinLv.Value = Convert.ToDecimal(text.Split('|')[1]);
                    _resfudu = value;
                    if (cbxScope2.SelectedIndex == 0)
                        numFuDu.Value = Convert.ToDecimal(_resfudu);
                    else if (cbxScope2.SelectedIndex == 1)
                    {
                        if (cbxQiangKou2.SelectedIndex == 0)
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                        else
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                    }
                    else if (cbxScope2.SelectedIndex == 2)
                    {
                        if (cbxQiangKou2.SelectedIndex == 0)
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                        else
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                    }
                    else if (cbxScope2.SelectedIndex == 3)
                    {
                        if (cbxQiangKou2.SelectedIndex == 0)
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                        else
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                    }
                    else if (cbxScope2.SelectedIndex == 4)
                    {
                        if (cbxQiangKou2.SelectedIndex == 0)
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                        else
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                    else if (cbxScope2.SelectedIndex == 5)
                    {
                        if (cbxQiangKou2.SelectedIndex == 0)
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                        else
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
                finally
                {
                    if (cbxAutoFire.Checked)
                        cbxSwitch.Checked = true;
                }
            }
            //开启/关闭压枪开关
            else if (e.KeyData == Keys.F2)
            {
                if (cbxSwitch.Checked)
                {
                    cbxSwitch.Checked = false;
                    if (cbxPlayVoice.Checked)
                        _pyqoff.Play();
                }
                else
                {
                    cbxSwitch.Checked = true;
                    if (cbxPlayVoice.Checked)
                        _pyqon.Play();
                }
            }
            //增加频率
            else if (e.KeyData == Keys.Up)
                numPinLv.Value = ++numPinLv.Value;
            //降低频率
            else if (e.KeyData == Keys.Down)
                numPinLv.Value = --numPinLv.Value;
            //降低幅度
            else if (e.KeyData == Keys.Left)
            {
                if (numFuDu.Value == 0m)
                    return;
                numFuDu.Value = --numFuDu.Value;
            }
            //增加幅度
            else if (e.KeyData == Keys.Right)
                numFuDu.Value = ++numFuDu.Value;
            else if (e.KeyData == Keys.F3)
            {
                if (cbxShiBie.Checked)
                {
                    int foregroundWindow = this._dm.GetForegroundWindow();
                    if (this._dm.GetWindowTitle(foregroundWindow) == "智能压枪")
                    {
                        return;
                    }
                    _shiBieTimer.Interval = 100;
                    _shiBieTimer.Enabled = true;
                }
            }
        }

        private void Unsubscribe()
        {
            if (_mEvents != null)
            {
                return;
            }
        }
        public static void Delay(int milliSecond)
        {
            var tickCount = Environment.TickCount;
            while (Math.Abs(Environment.TickCount - tickCount) < milliSecond)
            {
                Application.DoEvents();
            }
        }
        /// <summary>
        /// 读配置文件
        /// </summary>
        /// <param name="section"></param>
        /// <param name="skey"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public string IniReadValue(string section, string skey, string path)
        {
            var stringBuilder = new StringBuilder(500);
            GetPrivateProfileString(section, skey, "", stringBuilder, 500, path);
            return stringBuilder.ToString();
        }
        /// <summary>
        /// 写配置文件
        /// </summary>
        /// <param name="section"></param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="path"></param>
        public void IniWrite(string section, string key, string value, string path)
        {
            WritePrivateProfileString(section, key, value, path);
        }
        #endregion

        #region 第一行武器参数切换事件
        /// <summary>
        /// 武器1切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbxWeapon1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_wepon == 2) return;
            try
            {
                lblsc.Text = cbxScope1.Text + cbxWeapon1.Text;
                if (cbxWeapon1.Text == @"无")
                {
                    lblsc.Text = @"未知武器";
                }
                if (cbxAutoFire.Checked)
                {
                    if (cbxWeapon1.Text == @"M16A4" || cbxWeapon1.Text == @"Mini14")
                    {
                        cbxLianXu.Checked = true;
                    }
                    else
                    {
                        cbxLianXu.Checked = false;
                    }
                }
                int selectedIndex = cbxQiangKou1.SelectedIndex;
                var str = selectedIndex.ToString();
                selectedIndex = cbxWoBa1.SelectedIndex;
                var str2 = selectedIndex.ToString();
                selectedIndex = cbxQiangTuo1.SelectedIndex;
                var text = str + str2 + selectedIndex;
                if (text == "-1-1-1")
                {
                    text = "000";
                }
                var configText = IniReadValue(cbxWeapon1.Text, text, _strpath);
                var length = configText.IndexOf("|", StringComparison.Ordinal);
                var value = configText.Substring(0, length);
                numFuDu.Value = Convert.ToDecimal(value);
                numPinLv.Value = Convert.ToDecimal(configText.Split('|')[1]);
                _resfudu = value;
                if (cbxScope1.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu);
                }
                else if (cbxScope1.SelectedIndex == 1)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 2)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 3)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 4)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 5)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                    }
                }
            }
            catch
            {
                Application.Exit();
            }
        }

        /// <summary>
        /// 瞄具1切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbxScope1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_wepon == 2) return;
            lblsc.Text = cbxScope1.Text + cbxWeapon1.Text;
            if (cbxWeapon1.Text == "无")
            {
                lblsc.Text = "未知武器";
            }
            if (cbxScope1.SelectedIndex == 0)
            {
                numFuDu.Value = Convert.ToDecimal(_resfudu);
            }
            else if (cbxScope1.SelectedIndex == 1)
            {
                if (cbxQiangKou1.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                }
                else
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                }
            }
            else if (cbxScope1.SelectedIndex == 2)
            {
                if (cbxQiangKou1.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                }
                else
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                }
            }
            else if (cbxScope1.SelectedIndex == 3)
            {
                if (cbxQiangKou1.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                }
                else
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                }
            }
            else if (cbxScope1.SelectedIndex == 4)
            {
                if (cbxQiangKou1.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                }
                else
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                }
            }
            else if (cbxScope1.SelectedIndex == 5)
            {
                if (cbxQiangKou1.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                }
                else
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                }
            }
        }
        /// <summary>
        /// 枪口1切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbxQiangKou1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_wepon == 2) return;
            try
            {
                if (cbxWeapon1.Text == "无")
                {
                    lblsc.Text = "未知武器";
                }
                int selectedIndex = cbxQiangKou1.SelectedIndex;
                string str = selectedIndex.ToString();
                selectedIndex = cbxWoBa1.SelectedIndex;
                string str2 = selectedIndex.ToString();
                selectedIndex = cbxQiangTuo1.SelectedIndex;
                string text = str + str2 + selectedIndex.ToString();
                if (text == "0-1-1")
                {
                    text = "000";
                }
                string text2 = IniReadValue(cbxWeapon1.Text, text, _strpath);
                int length = text2.IndexOf("|");
                string value = text2.Substring(0, length);
                numFuDu.Value = Convert.ToDecimal(value);
                numPinLv.Value = Convert.ToDecimal(text2.Split('|')[1]);
                _resfudu = value;
                if (cbxScope1.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu);
                }
                else if (cbxScope1.SelectedIndex == 1)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 2)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 3)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 4)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 5)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                    }
                }
            }
            catch
            {
            }
        }
        /// <summary>
        /// 握把1切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbxWoBa1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_wepon != 2)
            {
                try
                {
                    if (cbxWeapon1.Text == "无")
                    {
                        lblsc.Text = "未知武器";
                    }
                    int selectedIndex = cbxQiangKou1.SelectedIndex;
                    string str = selectedIndex.ToString();
                    selectedIndex = cbxWoBa1.SelectedIndex;
                    string str2 = selectedIndex.ToString();
                    selectedIndex = cbxQiangTuo1.SelectedIndex;
                    string text = str + str2 + selectedIndex.ToString();
                    if (text == "00-1")
                    {
                        text = "000";
                    }
                    string text2 = IniReadValue(cbxWeapon1.Text, text, _strpath);
                    int length = text2.IndexOf("|");
                    string value = text2.Substring(0, length);
                    numFuDu.Value = Convert.ToDecimal(value);
                    numPinLv.Value = Convert.ToDecimal(text2.Split('|')[1]);
                    _resfudu = value;
                    if (cbxScope1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu);
                    }
                    else if (cbxScope1.SelectedIndex == 1)
                    {
                        if (cbxQiangKou1.SelectedIndex == 0)
                        {
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                        }
                        else
                        {
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                        }
                    }
                    else if (cbxScope1.SelectedIndex == 2)
                    {
                        if (cbxQiangKou1.SelectedIndex == 0)
                        {
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                        }
                        else
                        {
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                        }
                    }
                    else if (cbxScope1.SelectedIndex == 3)
                    {
                        if (cbxQiangKou1.SelectedIndex == 0)
                        {
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                        }
                        else
                        {
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                        }
                    }
                    else if (cbxScope1.SelectedIndex == 4)
                    {
                        if (cbxQiangKou1.SelectedIndex == 0)
                        {
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                        }
                        else
                        {
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                        }
                    }
                    else if (cbxScope1.SelectedIndex == 5)
                    {
                        if (cbxQiangKou1.SelectedIndex == 0)
                        {
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                        }
                        else
                        {
                            numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                        }
                    }
                }
                catch
                {
                }
            }
        }
        /// <summary>
        /// 枪托1切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbxQiangTuo1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_wepon == 2) return;
            try
            {
                if (cbxWeapon1.Text == "无")
                {
                    lblsc.Text = "未知武器";
                }
                int selectedIndex = cbxQiangKou1.SelectedIndex;
                string str = selectedIndex.ToString();
                selectedIndex = cbxWoBa1.SelectedIndex;
                string str2 = selectedIndex.ToString();
                selectedIndex = cbxQiangTuo1.SelectedIndex;
                string text = str + str2 + selectedIndex.ToString();
                if (text == "-1-1-1")
                {
                    text = "000";
                }
                string text2 = IniReadValue(cbxWeapon1.Text, text, _strpath);
                int length = text2.IndexOf("|");
                string value = text2.Substring(0, length);
                numFuDu.Value = Convert.ToDecimal(value);
                numPinLv.Value = Convert.ToDecimal(text2.Split('|')[1]);
                _resfudu = value;
                if (cbxScope1.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu);
                }
                else if (cbxScope1.SelectedIndex == 1)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 2)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 3)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 4)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                }
                else if (cbxScope1.SelectedIndex == 5)
                {
                    if (cbxQiangKou1.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                    }
                }
            }
            catch
            {
            }
        }
        #endregion

        #region 第二行武器参数切换事件
        /// <summary>
        /// 武器2切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbxWeapon2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_wepon == 1) return;
            try
            {
                lblsc.Text = cbxScope2.Text + cbxWeapon2.Text;
                if (cbxWeapon2.Text == "无")
                {
                    lblsc.Text = "未知武器";
                }
                if (cbxAutoFire.Checked)
                {
                    if (cbxWeapon2.Text == "M16A4" || cbxWeapon2.Text == "Mini14")
                    {
                        cbxLianXu.Checked = true;
                    }
                    else
                    {
                        cbxLianXu.Checked = false;
                    }
                }
                int selectedIndex = cbxQiangKou2.SelectedIndex;
                string str = selectedIndex.ToString();
                selectedIndex = cbxWoBa2.SelectedIndex;
                string str2 = selectedIndex.ToString();
                selectedIndex = cbxQiangTuo2.SelectedIndex;
                string text = str + str2 + selectedIndex;
                if (text == "-1-1-1")
                {
                    text = "000";
                }
                string text2 = IniReadValue(cbxWeapon2.Text, text, _strpath);
                int length = text2.IndexOf("|");
                string value = text2.Substring(0, length);
                numFuDu.Value = Convert.ToDecimal(value);
                numPinLv.Value = Convert.ToDecimal(text2.Split('|')[1]);
                _resfudu = value;
                if (cbxScope2.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu);
                }
                else if (cbxScope2.SelectedIndex == 1)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 2)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 3)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 4)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 5)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                    }
                }
            }
            catch
            {
                Application.Exit();
            }
        }

        /// <summary>
        /// 瞄具2切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbxScope2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_wepon == 1) return;
            lblsc.Text = cbxScope2.Text + cbxWeapon2.Text;
            if (cbxWeapon2.Text == "无")
            {
                lblsc.Text = "未知武器";
            }
            if (cbxScope2.SelectedIndex == 0)
            {
                numFuDu.Value = Convert.ToDecimal(_resfudu);
            }
            else if (cbxScope2.SelectedIndex == 1)
            {
                if (cbxQiangKou2.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                }
                else
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                }
            }
            else if (cbxScope2.SelectedIndex == 2)
            {
                if (cbxQiangKou2.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                }
                else
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                }
            }
            else if (cbxScope2.SelectedIndex == 3)
            {
                if (cbxQiangKou2.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                }
                else
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                }
            }
            else if (cbxScope2.SelectedIndex == 4)
            {
                if (cbxQiangKou2.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                }
                else
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                }
            }
            else if (cbxScope2.SelectedIndex == 5)
            {
                if (cbxQiangKou2.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                }
                else
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                }
            }
        }
        /// <summary>
        /// 枪口2切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbxQiangKou2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_wepon == 1) return;
            try
            {
                if (cbxWeapon2.Text == "无")
                {
                    lblsc.Text = "未知武器";
                }
                int selectedIndex = cbxQiangKou2.SelectedIndex;
                string str = selectedIndex.ToString();
                selectedIndex = cbxWoBa2.SelectedIndex;
                string str2 = selectedIndex.ToString();
                selectedIndex = cbxQiangTuo2.SelectedIndex;
                string text = str + str2 + selectedIndex.ToString();
                if (text == "-1-1-1")
                {
                    text = "000";
                }
                string text2 = IniReadValue(cbxWeapon2.Text, text, _strpath);
                int length = text2.IndexOf("|");
                string value = text2.Substring(0, length);
                numFuDu.Value = Convert.ToDecimal(value);
                numPinLv.Value = Convert.ToDecimal(text2.Split('|')[1]);
                _resfudu = value;
                if (cbxScope2.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu);
                }
                else if (cbxScope2.SelectedIndex == 1)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 2)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 3)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 4)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 5)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                    }
                }
            }
            catch
            {
            }
        }
        /// <summary>
        /// 握把2切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbxWoBa2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_wepon == 1) return;
            try
            {
                if (cbxWeapon2.Text == "无")
                {
                    lblsc.Text = "未知武器";
                }
                int selectedIndex = cbxQiangKou2.SelectedIndex;
                string str = selectedIndex.ToString();
                selectedIndex = cbxWoBa2.SelectedIndex;
                string str2 = selectedIndex.ToString();
                selectedIndex = cbxQiangTuo2.SelectedIndex;
                string text = str + str2 + selectedIndex.ToString();
                if (text == "-1-1-1")
                {
                    text = "000";
                }
                string text2 = IniReadValue(cbxWeapon2.Text, text, _strpath);
                int length = text2.IndexOf("|");
                string value = text2.Substring(0, length);
                numFuDu.Value = Convert.ToDecimal(value);
                numPinLv.Value = Convert.ToDecimal(text2.Split('|')[1]);
                _resfudu = value;
                if (cbxScope2.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu);
                }
                else if (cbxScope2.SelectedIndex == 1)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 2)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 3)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 4)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 5)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                    }
                }
            }
            catch
            {
            }
        }
        /// <summary>
        /// 枪托2切换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbxQiangTuo2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_wepon == 1) return;
            try
            {
                if (cbxWeapon2.Text == "无")
                {
                    lblsc.Text = "未知武器";
                }
                int selectedIndex = cbxQiangKou2.SelectedIndex;
                string str = selectedIndex.ToString();
                selectedIndex = cbxWoBa2.SelectedIndex;
                string str2 = selectedIndex.ToString();
                selectedIndex = cbxQiangTuo2.SelectedIndex;
                string text = str + str2 + selectedIndex.ToString();
                if (text == "-1-1-1")
                {
                    text = "000";
                }
                string text2 = IniReadValue(cbxWeapon2.Text, text, _strpath);
                int length = text2.IndexOf("|");
                string value = text2.Substring(0, length);
                numFuDu.Value = Convert.ToDecimal(value);
                numPinLv.Value = Convert.ToDecimal(text2.Split('|')[1]);
                _resfudu = value;
                if (cbxScope2.SelectedIndex == 0)
                {
                    numFuDu.Value = Convert.ToDecimal(_resfudu);
                }
                else if (cbxScope2.SelectedIndex == 1)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 5m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 4m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 2)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 11m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 8m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 3)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 15m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 4)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 29m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 21m;
                    }
                }
                else if (cbxScope2.SelectedIndex == 5)
                {
                    if (cbxQiangKou2.SelectedIndex == 0)
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 43m;
                    }
                    else
                    {
                        numFuDu.Value = Convert.ToDecimal(_resfudu) + 31m;
                    }
                }
            }
            catch
            {
            }
        }
        #endregion
    }
}
